package ru.nsu.fit.ws.get_user_stat;

import ru.nsu.fit.shared.data_base_manager.DatabaseManager;

import javax.jws.HandlerChain;
import javax.jws.WebService;

/**
 * @author Sergey Kozlov
 */

@WebService(endpointInterface = "ru.nsu.fit.ws.get_user_stat.UserStat")
@HandlerChain(file= "handler-chain.xml")
public class UserStatImpl implements UserStat {
    @Override
    public UserStatOutput getUserStat(final UserStatInput input) {
        if(input == null){
            return null;
        }
        try{
            final long userSessionId = input.getUserSessionId();
            return DatabaseManager.getUserStat(userSessionId);
        }
        catch (final Exception e){
            final UserStatOutput output = new UserStatOutput();
            output.setSuccessful(false);
            output.setErrorMessage(e.getMessage());
            return output;
        }
    }
}
